package pl.pawluk.inz.entities;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created with IntelliJ IDEA.
 * User: mandp
 * Date: 17.05.13
 * Time: 19:39
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "users", schema = "public", catalog = "")
@Entity
public class UsersEntity {
    private Long id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 19, precision = 0)
    @Id
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    private String email;

    @javax.persistence.Column(name = "email", nullable = false, insertable = true, updatable = true, length = 255, precision = 0)
    @Basic
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    private String password;

    @javax.persistence.Column(name = "password", nullable = false, insertable = true, updatable = true, length = 80, precision = 0)
    @Basic
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    private Boolean active;

    @javax.persistence.Column(name = "active", nullable = false, insertable = true, updatable = true, length = 1, precision = 0)
    @Basic
    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean actiive) {
        this.active = actiive;
    }

    private String firstName;

    @javax.persistence.Column(name = "first_name", nullable = true, insertable = true, updatable = true, length = 128, precision = 0)
    @Basic
    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    private String middleName;

    @javax.persistence.Column(name = "middle_name", nullable = true, insertable = true, updatable = true, length = 128, precision = 0)
    @Basic
    public String getMiddleName() {
        return middleName;
    }

    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }

    private String surname;

    @javax.persistence.Column(name = "surname", nullable = false, insertable = true, updatable = true, length = 128, precision = 0)
    @Basic
    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    private String address;

    @javax.persistence.Column(name = "address", nullable = false, insertable = true, updatable = true, length = 512, precision = 0)
    @Basic
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    private String city;

    @javax.persistence.Column(name = "city", nullable = false, insertable = true, updatable = true, length = 128, precision = 0)
    @Basic
    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    private String zipCode;

    @javax.persistence.Column(name = "zip_code", nullable = false, insertable = true, updatable = true, length = 5, precision = 0)
    @Basic
    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UsersEntity that = (UsersEntity) o;

        if (active != null ? !active.equals(that.active) : that.active != null) return false;
        if (address != null ? !address.equals(that.address) : that.address != null) return false;
        if (city != null ? !city.equals(that.city) : that.city != null) return false;
        if (email != null ? !email.equals(that.email) : that.email != null) return false;
        if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) return false;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (middleName != null ? !middleName.equals(that.middleName) : that.middleName != null) return false;
        if (password != null ? !password.equals(that.password) : that.password != null) return false;
        if (surname != null ? !surname.equals(that.surname) : that.surname != null) return false;
        if (zipCode != null ? !zipCode.equals(that.zipCode) : that.zipCode != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + (active != null ? active.hashCode() : 0);
        result = 31 * result + (firstName != null ? firstName.hashCode() : 0);
        result = 31 * result + (middleName != null ? middleName.hashCode() : 0);
        result = 31 * result + (surname != null ? surname.hashCode() : 0);
        result = 31 * result + (address != null ? address.hashCode() : 0);
        result = 31 * result + (city != null ? city.hashCode() : 0);
        result = 31 * result + (zipCode != null ? zipCode.hashCode() : 0);
        return result;
    }

    private Collection<AuthoritiesEntity> authoritiesesById;

    @OneToMany(mappedBy = "userId", cascade = CascadeType.ALL)
    public Collection<AuthoritiesEntity> getAuthoritiesesById() {
        return authoritiesesById;
    }

    public void setAuthoritiesesById(Collection<AuthoritiesEntity> authoritiesesById) {
        this.authoritiesesById = authoritiesesById;
    }
}
